package com.zlq.cn.controller.sign.dzmy;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zlq.cn.api.SignApiResult;
import com.zlq.cn.config.Config;
import com.zlq.cn.dto.param.FanyiFeedbackParam;
import com.zlq.cn.dto.param.VipUpParam;
import com.zlq.cn.entity.FanyiUser;
import com.zlq.cn.entity.SuggestRecord;
import com.zlq.cn.service.un.FanyiUserService;
import com.zlq.cn.service.un.SuggestRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhoucl
 * @since 2022-03-05
 */
@Api(tags = "电子木鱼-用户")
@Validated
@RestController
@RequestMapping("/dzmy/user")
public class DzmyUserController {

    @Resource
    private FanyiUserService fanyiUserService;

    @Resource
    private SuggestRecordService suggestRecordService;

    @ApiOperation("获取服务器时间")
    @GetMapping("/sys/time")
    public SignApiResult<Long> sysTime() {
        return SignApiResult.resultSuccess(System.currentTimeMillis());
    }

    @ApiOperation("用户登录/注册")
    @PostMapping("/login")
    public SignApiResult<FanyiUser> login(@RequestBody Object o) {
        return SignApiResult.resultSuccess(fanyiUserService.login(Config.PROJECT_DZMY));
    }

    @ApiOperation("用户VIP上报")
    @PostMapping("/vip/up")
    public SignApiResult<Object> vipUp(@Valid @RequestBody VipUpParam vipUpParam) {
        vipUpParam.setCheckBuyAppVerify(Boolean.FALSE);
        return SignApiResult.resultSuccess(fanyiUserService.vipUp(vipUpParam));
    }

    @ApiOperation("用户反馈")
    @PostMapping("/feedback")
    public SignApiResult<Object> feedback(@RequestBody FanyiFeedbackParam fanyiFeedbackParam) {
        return SignApiResult.resultSuccess(fanyiUserService.feedback(fanyiFeedbackParam));
    }

    @ApiOperation("用户反馈列表")
    @PostMapping("/feedback/list")
    public SignApiResult<Page<SuggestRecord>> feedbackList(@RequestBody Page<SuggestRecord> page) {
        return SignApiResult.resultSuccess(suggestRecordService.lambdaQuery().page(page));
    }
}

